<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<base href="<?php echo base_url() . "application/assets/";?>"/>
	<title><?php echo $title; ?></title>
	<?php echo $_styles; ?>
	<?php echo $_scripts; ?>
	<script type="text/javascript">
$(function() {
		var controller='<?php echo $controller;?>';
		var func='<?php echo $function;?>';
		if(controller != "customer"){
			$( "#txtSearch" )
			// don't navigate away from the field on tab when selecting an item
			  .bind( "keydown", function( event ) {
				if ( event.keyCode === $.ui.keyCode.TAB &&
					$( this ).data( "ui-autocomplete" ).menu.active ) {
				  event.preventDefault();
				}
			  })
			.autocomplete({
				source: "<?php echo base_url()?>customer/search",
				focus: function() {
				  // prevent value inserted on focus
				  //return false;
				},
				minLength: 1,
				select: function( event, ui ) {
					//kiem tra khach hang co dang thuc hien giao dich ma chu hoan thanh ko????
					$.ajax({
							type:'post',
							url:'<?php echo base_url();?>transaction/check_transaction_customer',
							data:{
								cust_id:ui.item.id//Cust_ID
							},
							success:function(data){
								if(parseInt(data)>0) location.href="<?php echo base_url()?>transaction/chitietgiaodich/" + parseInt(data);
								else{
									$("#txtSearchCust_ID").val(ui.item.id);
									if( func=="giaodich" || func == "chitietgiaodich")
										location.href="<?php echo base_url();?>transaction/chitietgiaodich/?Cust_ID="+ui.item.id;
									if( func=="thanhtoan" || func == "chitietthanhtoan")
										location.href="<?php echo base_url();?>transaction/chitietgiaodich/?Cust_ID="+ui.item.id;
								}
							}
						});
					
				}
			});
		}else{
			if(controller == "customer"){
				$("#btnSearch").click(function(){
					$("#frmSearch").submit();
				});
			}
		}
		$( "#DOB" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		}).change(function(){
			
		});
		// $("#datepicker").datepicker("setDate",new Date());
		//$("#datepicker").datepicker("setDate",new Date(2012,09,20));
		//$( "#datepicker" ).change();
		$( "#Create_Dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		}).change(function(){
			
		});
		$( "#thuchi_dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'mm/yy',
			onClose: function(dateText, inst) { 
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
        },		
			
		}).change(function(){
			
		});
		$( "#statistics_dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		}).change(function(){
			
		});
		$( "#Hired_Dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		});
		$( "#Term_Dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		});
		$( "#Eff_Dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		});
		$( "#Exp_Dt" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		});
	});

</script>
</head>
<body><?php echo $header;?>
	<?php if($username) echo $content; else {?>
	</div>
	<?php }?>
	<!-- 3rd div level 1 - footer -->
	<?php echo $footer;?>
</body>
</html>
<script type="text/javascript">
function deletechecked(link)
{
    var answer = confirm('Delete item?')
    if (answer){
        window.location = link;
    }
    
    return false;  
}

</script>